package com.zeng.rest;

import com.zeng.rest.util.URLUtils;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.Map;

public class RestClientPostDemo {

    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("msg1", "hello");
        Entity<Map<String, String>> entity = Entity.entity(map, MediaType.APPLICATION_JSON_TYPE);
        Client client = ClientBuilder.newClient();
        Response response = client
                .target("http://localhost:8089/hello")        // WebTarget
                .request()                                              // Invocation.Builder
                .post(entity);

        Map content = response.readEntity(Map.class);

        System.out.println(content);

    }
}
